﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using EnvDTE;
using EnvDTE80;
using System.IO;
using ChaosEngine.EngineCore;
using ChaosEngine.GPU.Core;

namespace VividViewer
{
    public partial class ViewerPanel : UserControl
    {
        public vGPUCore GPU = null;
  
        public Timer RenTime;

        public ViewerPanel()
        {
            InitializeComponent();
            InitGPU("DX10");

            GPU.EmbedCore(panel1, "VividViewer");
            RenTime = new Timer();
            RenTime.Interval = (1000 / 30);
            RenTime.Tick += new EventHandler(Tick_Render);
            RenTime.Enabled = true;
        }
        public void Tick_Render(object own, EventArgs arg)
        {

            GPU.EmbedBeginDraw();

            GPU.EmbedEndDraw();

        }

        private void InitGPU(string api)
        {
            RegisterGPUPrototypes(); // Ripped from the main engine source, just to show you how it is done.
            GPU = VividApp.GPU.Map[api].SpawnInstance();

            GPU.InitCore();

        }

        private void RegisterGPUPrototypes()
        {


            VividApp.GPU.Map.Add("DX10", new ChaosEngine.GPU.API.DirectX.GCDX10());
            VividApp.GPU.Map.Add("DX11", new ChaosEngine.GPU.API.DirectX.GCDX11());

        }

        private DTE2 m_dte;
        // Reference to the Visual Studio DTE object


        /// <summary>
        /// Receives the VS DTE object
        /// </summary>
        public DTE2 DTE
        {
            set
            {
                m_dte = value;
            }
        }
    }
}
